#include <stdio.h>
#include <string.h>

#include "els.h"
#include "inout.h"
#include "els_c_api.h"
#define ELS_VERSION	"ELS(Easylosu Script)编程语言 V0.4.0"
#define ELS_COPYRIGHT	"Copyright (C) 2022-2023 easylosu@lists.openkylin.top"
#define ELS_AUTHORS 	"Chen-Chaochen,Guo-Yichen,Ma-Ming"

static int els_argc;
static char **els_argv;

static void els_getargv (void){
    els_Typesystem_Object lo = els_getstack(1);
    if (!els_isnum(lo)) els_pushnull();
    else{
        int n = (int)els_getnum(lo);
        if (n > els_argc-2) els_pushstr("");
        else els_pushstr(els_argv[n+1]);
    }
}
static void els_getargc (void){
    els_pushnum(els_argc-2);
}


int main (int argc, char *argv[]){
    int i;
    char s;
    els_argc = argc;
    els_argv = argv;
    
    
    els_register("参数", els_getargv);
    els_register("参数个数", els_getargc);
    
    els_register("argv", els_getargv);
    els_register("argc", els_getargc);

    els_load_lib();
    if (argc < 2){
        printf("%s\n%s\nCreated by\t%s\n",ELS_VERSION, ELS_COPYRIGHT, ELS_AUTHORS);
        return 0;
    }else{
        i= els_dofile (argv[1]);
    }
    scanf("%c",&s);
    return i;
}




